programming4us
           
 
 
Windows

SOA with .NET and Windows Azure : Windows Workflow Foundation (part 5) - WF Programming Model

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/19/2010 4:36:38 PM

Workflow Runtime Environment

A workflow instance is created and executed by the workflow runtime engine. The runtime engine relies on several runtime services for persisting the workflow’s state, managing transactions, tracking workflow’s execution, and other features. Each instance of the runtime engine can support multiple instances of a workflow concurrently. The workflow instance runs in a host process or in an application domain and can be hosted on ASP.NET Web sites, Windows forms, Windows services, Web services, or SharePoint.

The runtime engine is powered by runtime services that provide an execution environment for transactions, persistence, tracking changes, timer, and threading. Runtime services can be augmented by plugging in custom services that allow changing the behavior of the runtime engine to meet the specific needs of the execution environment.

For most workflow implementations, the default implementation of runtime services satisfies the needs of the execution; however, in some cases the behavior may need to be altered. For example, the workflow may require the host application and the runtime engine to communicate differently, which would require building custom services.

The workflow execution starts by creating an instance of the workflow. It proceeds with carrying out activities until it is required to idle the execution, at which point the instance state is persisted to disk.

WF Programming Model

WF classes are encapsulated in three namespaces, as shown in Figure 3.

Figure 3. Workflow Foundation classes are encapsulated in three namespaces. The System.Workflow.Runtime assembly further contains the WorkflowRuntime class that is used to create an instance of a workflow.


Figure 4 illustrates a simple sequential workflow that contains a Calculator activity. To automate this workflow, the host will need to instantiate it and provide it with parameters including the input values and the operation to perform.

Figure 4. A simple sequential workflow containing one activity that represents calculation logic.


In the following example, we show this workflow hosted in a console application:

Example 1.
using System.Workflow.Runtime.Hosting;
namespace WFWorkflow
{
class Program
{
static void Main(string[] args)
{
using(WorkflowRuntime
workflowRuntime = new WorkflowRuntime())
{
AutoResetEvent
waitHandle = new AutoResetEvent(false);
workflowRuntime.WorkflowCompleted
+= delegate
(object sender,
WorkflowCompletedEventArgs e)
{waitHandle.Set();};
workflowRuntime.WorkflowTerminated
+= delegate
(object sender,
WorkflowTerminatedEventArgs e)
}
{
Console.WriteLine(e.Exception.Message);
waitHandle.Set();
};
WorkflowInstance instance =
workflowRuntime.CreateWorkflow
(typeof(WFWorkflow.CalcWorkflow));
instance.Start();
waitHandle.WaitOne();
}
}
}
}


In the preceding example, the host process initiates the workflow runtime and then starts the workflow method itself. The workflow runtime is started up by instantiating the workflowRuntime class. Passing in the workflow type to the CreateWorkflow method then creates a workflow instance class. The Start method on the workflow instance kicks off the workflow business process.

There are several events raised by the workflow runtime environment. These include WorkflowCompleted and WorkflowTerminated (the latter of which is called when there is an error). The previous example uses anonymous delegates, as WorkflowTerminatedEventArgs provides information on the exception that was generated. When the WorkflowCompleted event is called, we set the waitHandle value.

Other -----------------
- Windows 7 : Creating and Enforcing Bulletproof Passwords (part 3) - Recovering from a Forgotten Password
- Windows 7 : Creating and Enforcing Bulletproof Passwords (part 2) - Taking Advantage of Windows 7’s Password Policies
- Windows 7 : Creating and Enforcing Bulletproof Passwords (part 1)
- Windows 7 : Understanding User Account Control (part 3) - User Account Control Policies
- Windows 7 : Understanding User Account Control (part 2) - Configuring User Account Control
- Windows 7 : Understanding User Account Control (part 1) - Elevating Privileges
- Windows 7 : Encrypting a Disk with BitLocker (part 2) - Enabling BitLocker on a System Without a TPM
- Windows 7 : Encrypting a Disk with BitLocker (part 1) - Enabling BitLocker on a System with a TPM
- Windows 7 : Securing the File System - Encrypting Files and Folders
- SOA with .NET and Windows Azure : Service Consumers with WCF
- Windows 7 : Setting Security Permissions on Files and Folders (part 5) - Assigning Special Permissions
- Windows 7 : Setting Security Permissions on Files and Folders (part 4) - Assigning Standard Permissions
- Windows 7 : Setting Security Permissions on Files and Folders (part 3) - Assigning a User to Multiple Security Groups
- Windows 7 : Setting Security Permissions on Files and Folders (part 2) - Assigning a User to a Security Group
- Windows 7 : Setting Security Permissions on Files and Folders (part 1) -
- Cloud-Enabling the ESB with Windows Azure (part 2) - Sending Messages to Azure’s AppFabric Service Bus
- Cloud-Enabling the ESB with Windows Azure (part 1) - Receiving Messages from Azure’s AppFabric Service Bus
- Windows 7 : Sending and Receiving Secure Email (part 2) - Obtaining Another Person’s Public Key
- Windows 7 : Sending and Receiving Secure Email (part 1) - Setting Up an Email Account with a Digital ID
- Windows 7 : Maintaining Your Privacy While Reading Email
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us